<?php
require_once (dirname ( __FILE__ ) . '/intface/intface.application.php');
class ConsoleApplication extends iApplication {
	public function runFirst() {
		$this->view->assign ( 'CORE_CSS_VERSION', CORE_CSS_VERSION ); // 核心css版本号
		$this->view->assign ( 'CORE_JS_VERSION', CORE_JS_VERSION ); // 核心js版本号
	}
	public function runLast() {
		Log::commit();
	}
	
	/**
	 * 初始化 application 对像
	 *
	 * @param
	 *        	void
	 * @return void
	 */
	public function initialize() {
		$this->appRoot = dirname ( $_SERVER ['SCRIPT_FILENAME'] ) . "/";
		ini_set ( 'include_path', ini_get ( 'include_path' ) . _PATH_SEPARATOR . $this->appRoot );
		
		@set_magic_quotes_runtime ( false ); // 加了个@，新版本php中废弃了此函数
		
		$this->config = core::Singleton ( 'comm.application.config.Config' );
		require_once ('comm/application/intface/intface.view.php');
		$this->view = core::Singleton ( 'comm.application.view.DefaultView' );
		require_once ('comm/application/intface/intface.cron.php');
		
		$arg = $_SERVER ['argv'];
		$fileName = 'cron/action/' . $arg [1] . '.php';
		$this->action = $this->loadModule ( $fileName, $arg [1], 'cron' );
		$this->action->setView ( $this->view );
		$this->view->setConfig ( $this->config );
	}
}